<?php
	$labels = array();
	$func	= array('view', 'delete', 'edit');
	$query = 'select * from '.$table.' order by id desc';
	$link = '';
	$title = substr($titles[array_search($table, $tables)], 1);
	$addbtn = true;
	$_SESSION['table'] = $table;

	switch($table) {

		case 'subscriptions':
			$addbtn = false;
			$query = 'select id, userid, startdate, enddate, paid from '.$table.' where subscriptiontypeid = '.$post_id;
			$labels = array('id', 'Subscriber', 'Start Date', 'End Date', 'Paid');
			$func	= array();
			break;

		case 'company_users':
			$query = 'select id, name, mob, email, accesscode from '.$table.' where companyid = '.$post_id;
			$labels = array('id', 'Name', 'Mobile Number', 'Email', 'Access Code');
			$func	= array('delete', 'edit');
			break;

		case 'spaces':
			$query = 'select id, label, capacity, mintime, maxtime, hourlyrate from '.$table.' where buildingid = '.$post_id;
			$labels = array('id', 'Label', 'Capacity', 'Min Booking Time', 'Max Booking Time', 'Hourly Rate');
			$func = array('delete', 'edit');
			break;
	}

	echo "<h2>$title</h2>";
	if ($addbtn) echo "<a class=\"add_new\" href=\"".$path.$table."/add/$post_id\"><img src=\"".$path."img/blank.gif\" alt=\"\" /> Add a new entry</a>\n";
	echo $cn->OutputTable($query, $labels, $func, 'table list-table', false);
?>